import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";

Vue.config.productionTip = false;

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

/**
 * 时间格式化
 */
 Date.prototype.format = function (fmt = 'yyyy-MM-dd HH:mm:ss') {
  /**
   * 日期数据
   */
  const opts = {
    'y+': this.getFullYear().toString(),
    'M+': (this.getMonth() + 1).toString(),
    'd+': this.getDate().toString(),
    'H+': this.getHours().toString(),
    'm+': this.getMinutes().toString(),
    's+': this.getSeconds().toString(),
    'f+': this.getMilliseconds().toString()
  }
  for (const key in opts) {
    const value = opts[key]; //时间值
    if (new RegExp(`(${key})`).test(fmt)) {
      const result = RegExp.$1; //如果匹配成功则可以获取到结果
      fmt = fmt.replace(result, value.padStart(result.length, '0'));
    }
  }
  return fmt;
}


import Router from 'vue-router'
//防止路由多次点击出错
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}


new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
